#include<iostream>
#include<unistd.h>
#include<sys/types.h>
#include<signal.h>
#include<sys/wait.h>

void handler(int)
{
    sleep(1);
    std::cout<<"子进程向父进程发送了SIGCHLD"<<std::endl;
}
int main()
{
    signal(SIGCHLD,handler);
    pid_t pid=fork();
    if(pid==0)//子进程
    {
        sleep(1);
        std::cout<<"chlid process working"<<std::endl;
        exit(0);
    }
    wait(0);
    std::cout<<"实验成功"<<std::endl;
    return 0;
}